package com.nxmu.hire.common.util;

import com.nxmu.hire.common.constant.ResponseCode;

import java.io.Serializable;

/**
 * 返回报文
 * @author 
 */
public class ResponseResult implements Serializable{

    /**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public static final String SUCCESS = "success";

    public static final String FAILURE = "failure";

    /**
     * 状态码
     */
    private int status;

    /**
     * 消息
     */
    private String message;

    /**
     * 数据
     */
    private Object data;

    /**
     * 分页信息
     */
    private Page page;

    public ResponseResult() {
    }

    public ResponseResult(int status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public static ResponseResult success(String message, Object data) {
        return new ResponseResult(ResponseCode.SUCCESS, message, data);
    }

    public static ResponseResult success(String message) {
        return new ResponseResult(ResponseCode.SUCCESS, message, null);
    }

    public static ResponseResult success(Object data) {
        return new ResponseResult(ResponseCode.SUCCESS, SUCCESS, data);
    }

    public static ResponseResult success() {
        return new ResponseResult(ResponseCode.SUCCESS, SUCCESS, null);
    }

    public static ResponseResult fail(String message, Object data) {
        return new ResponseResult(ResponseCode.FAILURE, message, data);
    }

    public static ResponseResult fail(String message) {
        return new ResponseResult(ResponseCode.FAILURE, message, null);
    }

    public static ResponseResult fail(Object data) {
        return new ResponseResult(ResponseCode.FAILURE, FAILURE, data);
    }

    public static ResponseResult fail() {
        return new ResponseResult(ResponseCode.FAILURE, FAILURE, null);
    }

    public Page getPage() {
        return page;
    }

    public ResponseResult setPage(Page page) {
        this.page = page;
        return this;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


}
